<!-- Busqueda -->
<div class="panel panel-primary">
    <div class="panel-heading">
        <h3 class="panel-title">Busqueda</h3>
    </div>
    <div class="panel-body">
        <form class="form-inline" name="frmBusqueda" method="POST" role="form">
            <div class="form-group">
                <label class="sr-only" for="txtDNILegajo">DNI o N&ordm; de Legajo</label>
                <input id="txtDNILegajo" class="form-control" name="txtDNILegajo" type="number" min="1" step="1" placeholder="DNI o N&ordm; Legajo">
            </div>
            <button type="submit" name="btnFiltrar" class="btn btn-default">
                <span class="glyphicon glyphicon-filter"></span> Filtrar
            </button>
        </form>
    </div>
</div>
<!-- Datos del pedido -->
<div id="pnlDatosPedido" class="panel panel-info">
    <div class="panel-heading">
        <h3 class="panel-title">Datos del pedido</h3>
    </div>
    <div class="panel-body">
        <form class="form-horizontal" name="frmPedido" method="POST" role="form">
            <fieldset>
                <!-- Datos de la persona -->
                <div class="panel panel-primary">
                    <div class="panel-heading">
                        <h3 class="panel-title">Datos de la persona</h3>
                    </div>
                    <div class="panel-body">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">Legajo</label>
                            <div class="col-sm-4">
                                <input name="hidIdUsuario" type="hidden" value="{IdUsuario}" />
                                <p class="form-control-static">{Legajo}</p>
                            </div>
                            <label class="col-sm-2 control-label">DNI</label>
                            <div class="col-sm-4">
                                <p class="form-control-static">{DNI}</p>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">Nombre</label>
                            <div class="col-sm-4">
                                <p class="form-control-static">{Nombre}</p>
                            </div>
                            <label class="col-sm-2 control-label">Apellido</label>
                            <div class="col-sm-4">                    
                                <p class="form-control-static">{Apellido}</p>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">Telefono</label>
                            <div class="col-sm-4">
                                <p class="form-control-static">{Telefono}</p>
                            </div>
                            <label class="col-sm-2 control-label">Celular</label>
                            <div class="col-sm-4">                    
                                <p class="form-control-static">{Celular}</p>
                            </div>
                        </div>
                    </div>
                </div>
                <!-- Datos del pedido -->
                <div class="form-group">
                    <label class="col-sm-1 control-label" for="txtCreado">Creado</label>
                    <div class="col-sm-2">
                        <input id="txtCreado" class="form-control" name="txtCreado" type="text" value="{Creado}" readonly="readonly" required="required" />
                    </div>
                    <label class="col-sm-2 control-label" for="txtRetiro">Retiro</label>
                    <div class="col-sm-2">
                        <input id="txtRetiro" class="form-control" name="txtRetiro" type="text" required="required" />
                    </div>
                    <label class="col-sm-2 control-label">Franja</label>
                    <div class="col-sm-2">
                        <select id="ddlFranja" class="form-control" name="ddlFranja">
                            {combo_franja_horario}
                        </select>
                    </div>
                </div>
                <!-- Item -->
                <div class="panel panel-success">
                    <div class="panel-heading">
                        <h3 class="panel-title">Item</h3>
                    </div>
                    <div class="panel-body">
                        <div class="table-responsive">
                            <table class="table table-hover">
                                <thead>
                                    <tr>
                                        <th>Descripcion</th>
                                        <th>Hojas</th>
                                        <th>Anillado</th>
                                        <th>Abrochado</th>
                                        <th>Simple Faz</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <tr>
                                        <td>
                                            <input class="form-control" name="txtDescripcionItem" type="text" maxlength="50" required="required" />
                                        </td>
                                        <td>
                                            <input class="form-control" name="txtHojas" type="number" value="0" step="1" min="1" max="10000" readonly="readonly" required="required" />
                                        </td>
                                        <td>
                                            <div class="checkbox">
                                                <label>
                                                    <input id="chkAnillado" name="chkAnillado" type="checkbox" />
                                                </label>
                                            </div>
                                        </td>
                                        <td>
                                            <div class="checkbox">
                                                <label>
                                                    <input id="chkAbrochado" name="chkAbrochado" type="checkbox" />
                                                </label>
                                            </div>
                                        </td>
                                        <td>
                                            <div class="checkbox">
                                                <label>
                                                    <input name="chkSimpleFaz" type="checkbox" />
                                                </label>
                                            </div>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-offset-10 col-sm-1">
                        <button class="btn btn-default hidden-print" name="btnGuardar" type="submit">
                            <span class="glyphicon glyphicon-floppy-disk"></span> Guardar
                        </button>
                    </div>
                    <div class="col-sm-1">
                        <a class="btn btn-default hidden-print" href="index.php?do=/atpublico/index">
                            <span class="glyphicon glyphicon-arrow-left"></span> Volver
                        </a>
                    </div>
                </div>
            </fieldset>
        </form>
    </div>
</div>
<script type="text/javascript">        
    var natDays = [{Feriados}];

    function noWeekendsOrHolidays(date) {
        var noWeekend = $.datepicker.noWeekends(date);
        if(noWeekend[0]) {
            return nationalDays(date);
        } else {
            return noWeekend;
        }
    }
    
    function nationalDays(date) {
        for(i = 0; i < natDays.length; i++) {
            if (date.getMonth() == natDays[i][0] - 1 && date.getDate() == natDays[i][1]) {
                return [false, natDays[i][2] + '_day'];
            }
        }
        return [true, ''];
    }
    
    function AddWeekDays(weekDaysToAdd) {
        var daysToAdd = 0;
        var mydate = new Date();
        var day = mydate.getDay();
        weekDaysToAdd = weekDaysToAdd - (5 - day);
        if((5 - day) < weekDaysToAdd || weekDaysToAdd == 1) {
            daysToAdd = (5 - day) + 2 + daysToAdd;
        } else { // (5-day) >= weekDaysToAdd
            daysToAdd = (5 - day) + daysToAdd;
        }
        while(weekDaysToAdd != 0) {
            var week = weekDaysToAdd - 5;
            if(week > 0) {
                daysToAdd = 7 + daysToAdd;
                weekDaysToAdd = weekDaysToAdd - 5;
            } else { // week < 0
                daysToAdd = (5 + week) + daysToAdd;
                weekDaysToAdd = weekDaysToAdd - (5 + week);
            }
        }

        return daysToAdd;
    }
    
    $("form[name=frmPedido]").submit(function(e) {
        //console.debug($("#txtRetiro").val());
        if($("#txtRetiro").val() == "") {
            e.preventDefault();
            alert("Eliga una fecha para el retiro del pedido.");
        }
    });
    
    $('#txtRetiro').datepicker({
        minDate: 0,
        dateFormat: "yy-mm-dd",
        changeMonth: true,
        changeYear: true,
        showAnim: "slideDown",
        beforeShowDay: noWeekendsOrHolidays //$.datepicker.noWeekends
    });
    
    $("#chkAnillado").click(function() {
        if(this.checked) {
            $("#chkAbrochado").prop("checked", false);
        }
    });
    
    $("#chkAbrochado").click(function() {
        if(this.checked) {
            $("#chkAnillado").prop("checked", false);
        }
    });
</script>